import java.util.concurrent.atomic.AtomicStampedReference;

public class AtomicStampedReferenceDemo1 {
    public static void main(String[] args) {
        AtomicStampedReference<String> ref = new AtomicStampedReference<>("Hello", 0);
        ref.compareAndSet("Hello", "World",
                0, 1); // 更新引用和版本号
        System.out.println(ref.getReference());//expectedStamp和initialStamp相等，
                                               // 则更新initialRef引用值为newReference，并且更新版本号
    }
}
